/*
 * @Author: Clark
 * @Email: haixuanwoTxh@gmail.com
 * @Date: 2023-01-28 15:53:38
 * @LastEditors: Clark
 * @LastEditTime: 2023-01-28 15:58:22
 * @Description: file content
 */
#include <limits.h>
#include <string.h>

#define MAXSTRINGSZ 4096

static char envbuf[MAXSTRINGSZ] = {0};
extern char **environ;

char *getenv(const char *name)
{
    int len = strlen(name);

    for (size_t i = 0; NULL != environ[i]; i++)
    {
        if ((0 == strncmp(name, environ[i], len)) && ('=' == environ[i][len]))
        {
            strncpy(envbuf, &environ[i][len+1], MAXSTRINGSZ -1);
            return envbuf;
        }
    }

    return NULL;
}
